#pragma once

#include <string>

#include <boost/type_traits.hpp>
#include <rapidjson/document.h>

namespace tb {

namespace serializer {

#define CPP2JSON_TYPE_SCHEMA_NAME(t) #t".json"

bool JsonTypeName(const char *jsonData, std::string &typeName);

void *CreateObject(const char *typeName);

void DestroyObject(const char *typeName, void *object);

bool Json2Object(std::string &typeName, cosnt char *jsonData, void *data, std::string &err);

// different from Json2Object we need not construct object first, just pass address of a pointer
bool Json2Object2(std::string &typeName, const char *jsonData, void **data, std::string &err);

bool Object2Json(const char *typeName, void *data, std::string &jsonData, std::string &err);

} // end namespace serializer

} // end namespace tb
